Linux下完全卸载mysql

查看mysql安装情况

1
rpm -qa|grep -i mysql
1
2
3
4
5
[root@iZ25rsnm9crfk8Z ~]# rpm -qa|grep -i mysql
mysql-community-libs-5.7.13-1.el6.x86_64
mysql-community-client-5.7.13-1.el6.x86_64
mysql-community-server-5.7.13-1.el6.x86_64
mysql-community-common-5.7.13-1.el6.x86_64

停止mysql服务

1
/etc/init.d/mysqld stop

同上删除所有安装的mysql

1
2
3
4
rpm -ev mysql-community-libs-5.7.13-1.el6.x86_64 --nodeps
rpm -ev mysql-community-client-5.7.13-1.el6.x86_64 --nodeps
rpm -ev mysql-community-server-5.7.13-1.el6.x86_64 --nodeps
rpm -ev mysql-community-common-5.7.13-1.el6.x86_64 --nodeps
1
2
3
4
[root@iZ25rsnm9crfk8Z ~]# rpm -ev mysql-community-server-5.7.13-1.el6.x86_64 --nodeps
Preparing packages...
mysql-community-server-5.7.13-1.el6.x86_64
warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

查找所有mysql目录并删除

1
find / -name mysql
1
2
3
4
[root@iZ25rsnm9crfk8Z ~]# find / -name mysql
/var/lib/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql

删除 :

1
2
3
4
5
6
rm -rf /var/lib/mysql  
rm -rf /var/lib/selinux/targeted/active/modules/100/mysql
rm -rf /opt/mysql
rm -rf /usr/share/bash-completion/completions/mysql
rm -rf /usr/share/selinux/targeted/default/active/modules/100/mysql
rm -rf /usr/share/mysql

删除/etc/my.cnf

1
rm -f /etc/my.cnf

确认是否删除完毕

1
find / -name mysql
继开 wechat
欢迎加我的微信,共同交流技术